import $ from '../common';

Page({
  data: {
    info: [],
    tip: '上滑加载更多',
    page: 1,
  },
  getcampusList() {
    const{info,page,zonecode,group_uuid}=this.data
    $.get('/campus/group/lessons', {
      page,
      zonecode,
      group_uuid,
      limit:20,
    }, res => {
      if (res.lessons.length < 20) {
        this.data.tip = '已经到底了'
      } else {
        this.data.tip = '上滑加载更多'
      }
      this.data.page++
      this.setData({
        page: this.data.page,
        tip: this.data.tip,
        info: [...info, ...res.lessons]
      })

    })
  },
  onLoad(e) {
    const {group_uuid = ''} = e
    this.setData({
      group_uuid,
      zonecode: wx.getStorageSync('addresscode') || ''
    })
    this.getcampusList()
  },
  onShow() {},
  onReachBottom() {
    this.getcampusList()
    this.setData({
      tip:'加载中'
    })
  },
})